# -*- coding:utf-8 -*-

import wx

class MyForm(wx.Frame):
    
    def __init__(self, title):
        wx.Frame.__init__(self, None, title=title)
        
        self.pane = wx.Panel(parent=self)
        
        title = wx.StaticText(self.pane, label='Title in here')
        
        labelOne = wx.StaticText(self.pane, label='hw-version')
        self.inputTxtOne = wx.TextCtrl(self.pane)
        
        labelTwo = wx.StaticText(self.pane, label='sd-req')
        self.inputTxtTwo = wx.TextCtrl(self.pane)

        labelThree = wx.StaticText(self.pane, label='application-version')
        self.inputTxtThree = wx.TextCtrl(self.pane)

        labelFour = wx.StaticText(self.pane, label='application')
        self.inputTxtFour = wx.TextCtrl(self.pane)

        labelFive = wx.StaticText(self.pane, label='key-file')
        # self.inputTxtFive = wx.TextCtrl(self.pane)
        self.inputFive = wx.FileCtrl(self.pane)

        labelSix = wx.StaticText(self.pane, label='save_to')
        self.saveFilePath = wx.TextCtrl(self.pane)
        
        okBtn = wx.Button(self.pane, label='OK')
        cancelBtn = wx.Button(self.pane, label='Cancel')
        self.Bind(event=wx.EVT_BUTTON, handler=self.onOK, source=okBtn)
        self.Bind(event=wx.EVT_BUTTON, handler=self.onCancel, source=cancelBtn)
        
        
        topSizer = wx.BoxSizer(wx.VERTICAL)
        titleSizer = wx.BoxSizer(wx.HORIZONTAL)
        inputOneSizer = wx.BoxSizer(wx.HORIZONTAL)
        inputTwoSizer = wx.BoxSizer(wx.HORIZONTAL)
        inputThreeSizer = wx.BoxSizer(wx.HORIZONTAL)
        inputFourSizer = wx.BoxSizer(wx.HORIZONTAL)
        inputFiveSizer = wx.BoxSizer(wx.HORIZONTAL)
        SixthSizer = wx.BoxSizer(wx.HORIZONTAL)
        btnSizer = wx.BoxSizer(wx.HORIZONTAL)
        
        titleSizer.Add(title, 0, wx.ALL, 5)
        
        inputOneSizer.Add(labelOne, 0, wx.ALL, 5)
        inputOneSizer.Add(self.inputTxtOne, 1, wx.ALL|wx.EXPAND, 5)
        
        inputTwoSizer.Add(labelTwo, 0, wx.ALL, 5)
        inputTwoSizer.Add(self.inputTxtTwo, 1, wx.ALL|wx.EXPAND, 5)

        inputThreeSizer.Add(labelThree, 0, wx.ALL, 5)
        inputThreeSizer.Add(self.inputTxtThree, 1, wx.ALL | wx.EXPAND, 5)
        
        inputFourSizer.Add(labelFour, 0, wx.ALL, 5)
        inputFourSizer.Add(self.inputTxtFour, 1, wx.ALL|wx.EXPAND, 5)
        
        inputFiveSizer.Add(labelFive, 0, wx.ALL, 5)
        inputFiveSizer.Add(self.inputFive, 1, wx.ALL|wx.EXPAND, 5)

        SixthSizer.Add(labelSix, 0, wx.ALL, 5)
        SixthSizer.Add(self.saveFilePath, 1, wx.ALL|wx.EXPAND, 5)
        
        btnSizer.Add(okBtn, 0, wx.ALL, 5)
        btnSizer.Add(cancelBtn, 0, wx.ALL, 5)
        
        topSizer.Add(titleSizer, 0, wx.CENTER)
        topSizer.Add(wx.StaticLine(self.pane,), 0, wx.ALL|wx.EXPAND, 5)
        topSizer.Add(inputOneSizer, 0, wx.ALL|wx.EXPAND, 5)
        topSizer.Add(inputTwoSizer, 0, wx.ALL | wx.EXPAND, 5)
        topSizer.Add(inputThreeSizer, 0, wx.ALL | wx.EXPAND, 5)
        topSizer.Add(inputFourSizer, 0, wx.ALL | wx.EXPAND, 5)
        topSizer.Add(inputFiveSizer, 0, wx.ALL | wx.EXPAND, 5)
        topSizer.Add(SixthSizer, 0, wx.ALL | wx.EXPAND, 5)
        topSizer.Add(wx.StaticLine(self.pane,), 0, wx.ALL|wx.EXPAND, 5)
        topSizer.Add(btnSizer, 0, wx.ALL|wx.CENTER, 5)
        
        self.pane.SetSizer(topSizer)
        topSizer.Fit(self)
        
        
    def onOK(self, evt):
        print 'onOK handler'
        if self.inputTxtOne.GetValue().strip():
            print(self.inputTxtOne.GetValue())
        else:
            print("input 1 is empty")
        
    
    def onCancel(self, evt):
        self.closeProgram()
        
    def closeProgram(self):
        self.Close()
    
        
if __name__ == '__main__':
    app = wx.App()
    frame = MyForm("hey")
    frame.Show()
    app.MainLoop()